<extend name="Public/base"/>
<block name="style">
    <style type="text/css">
        .btn {

            background: #09c;
        }

        .btn:hover {
            background: #09c;
        }

        body {
            color: #000;
            font-family: '宋体';

        }

        .code {
            width: 135px;
            height: 40px;
            border: none;
            background: #4BBD00;
            color: #fff;
        }

        .side-sub-menu > li > .item {
            color: #000;
            font-family: '宋体';
            font-size: 15px;
            padding: 0px;
            line-height: 25px;
        }

        .sidebar {
            background: #3697A0;
            position: absolute;
        }

        form .form-item {
            width: 50%;

        }

        /* 头部Logo,主导航*/
        body {
            color: #000;
            font-family: '宋体';
            font-weight: 900;
        }

        .header {
            background-color: #3697A0;
            height: 45px;
        }

        /* 主导航 */
        .main-nav a {
            height: 45px;
            color: #150303;
        }

        .main-nav a:hover {
            height: 45px;
            background-color: #70bcf3;
            color: #150303;
        }

        .main-nav .current {
            height: 45px;
            background-color: #70bcf3;
        }

        .main-nav .current a {
            height: 45px;
            background-color: #70bcf3;
            color: #150303;
        }

        .logo {
            height: 45px;
            background: #ccc;
        }

        .sidebar {
            margin-top: -5px;
            background: #3697A0;
            color: #000;
            position: fixed;
            height: 110%;
            margin-top: -40px;
        }

        .subnav h3 {
            color: #000;
        }

        .main-nav {
            /*width:100%;*/
            float: none;
            height: auto;
        }

        .mainnav {
            /*height: auto;*/
            height: 100%;
        }

        .main-nav li {
            float: none;
            width: 180px;
        }


    </style>
</block>
<block name="body">
    <div class="main-title">
        <h2>支付宝配置</h2>
    </div>


    <!-- 标签页导航 -->
    <div class="tab-wrap" style="position:relative">
        <div class="tab-content">
            <ul class="tab-nav nav">
                <li data-tab="tab1" class="current"><a href="javascript:void(0);">支付宝配置</a></li>
                <li data-tab="tab3" class=""><a href="javascript:void(0);">平台支付宝配置</a></li>
            </ul>


            <!-- 手机网站支付配置  -->
            <div id="tab1" class="tab-pane in tab1">

                <div class="cf">
                    <div class="fl">
                        <button class="btn add_alipay">新增</button>

                    </div>


                </div>
                <div class="data-table table-striped">
                    <php>

                        $_list=D('Alipays')->select();

                    </php>

                    <table style="font-size:14px;">
                        <thead>
                        <tr>
                            <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>

                            <th>ID</th>
                            <th>

                                类型
                            </th>
                            <th>账号</th>
                            <th>名称</th>
                            <th>APPID</th>
                            <th>PID</th>
                            <th>支付宝公钥</th>
                            <th>支付宝密钥</th>
                            <!--<th>转出费率</th>-->
                            <th>到账支付宝账号</th>
                            <th>总收款</th>
                            <th>今日收款</th>
                            <th>最小额度</th>
                            <th>最高额度</th>
                            <th>使用状态</th>
                            <th>下架原因</th>

                            <th>转出费率</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <notempty name="_list">
                            <php>
                                $typelist = [
                                ['id' => 1,'value' => '手机网站支付'],
                                ['id' => 4,'value' => '手机网站支付花呗'],
                                ['id' => 5,'value' => '当面付信用卡']
                                ];
                            </php>
                            <volist name="_list" id="rows">
                                <tr>
                                    <td><input class="ids" type="checkbox" name="id[]" value="{$rows['id']}"/></td>

                                    <td>{$rows['id']}</td>
                                    <!--1=手机网站支付,4=手机网站支付花呗,5=当面付信用卡-->
                                    <td>
                                        <volist name="typelist"  id="vo">

                                        <if condition="$vo.id eq $rows['type']">{$vo.value}</if>

                                    </volist>
                                    </td>
                                    <td>{$rows['account']}</td>
                                    <td>{$rows['name']}</td>

                                    <td>{$rows.appid}</td>
                                    <td>{$rows.pid}</td>
                                    <td>

                                        <php> echo substr($rows['secret'], 0,15).'...';</php>
                                    </td>
                                    <td>
                                        <php> echo substr($rows['public'], 0,15).'...';</php>
                                    </td>
                                    <!--<td>{$rows.rate_out}</td>-->
                                    <td>{$rows.to_alipay}</td>

                                    <td>
                                        <php>
                                            $time1=strtotime(date("Ymd",strtotime("+1 day")));
                                            $time2=strtotime(date("Ymd"));
                                            $seller=$rows['account'];

                                            $td_sum=D('Xyk')->where(" status=1 and seller='$seller'")->sum('pay_money');

                                            echo "<font style='color:red'>$td_sum</font>";
                                        </php>
                                    </td>

                                    <td>
                                        <php>
                                            $time1=strtotime(date("Ymd",strtotime("+1 day")));
                                            $time2=strtotime(date("Ymd"));
                                            $seller=$rows['account'];

                                            $sum=D('Xyk')->where(" status=1 and seller='$seller' and pay_time between
                                            $time2 and $time1")->sum('pay_money');

                                            echo "<font style='color:red'>$sum</font>";
                                        </php>

                                    </td>

                                    <td>{$rows.min_quota}</td>
                                    <td>{$rows.max_quota}</td>


                                    <td>
                                        <php> if($rows['status']==0){
                                            echo '<font style="color:green">未测试</font>';
                                            }elseif($rows['status'] == 2){
                                            echo '<font style="color:red">异常</font>';
                                            }else{
                                            echo '上架中';
                                            }

                                        </php>
                                    </td>

                                    <td>{$rows.cause}</td>
                                    <td>{$rows.rate_out}</td>
                                    <td>


                                        <!--<button class="btn edit_alipay">修改</button>-->
                                        <button class="btn test_alipay" onclick="qrcode_div_click('{$rows.id}')">测试</button>

                                        <div id="qrcode_div{$rows.id}" data-id="{$rows.id}" style="display:none;width: 200px;height: 200px;"><img id="qrcode_img" src="{$Think.config.SITE}/home/test/getTestQrcode?id={$rows.id}&amount=1&type={$rows.type}"/></div>
                                        <button class="btn delete_alipay">删除</button>
                                        <input type="hidden" name="status" class="status" value="{$rows.status}">
                                        <php>
                                            if($rows['status']==0){
                                                echo '
                                                <button class="btn  to_change_alipay">上架</button>
                                                ';
                                            }elseif($rows['status'] == 2){

                                            }else{
                                            echo '
                                            <button class="btn  to_change_alipay">下架</button>
                                            ';
                                            }

                                        </php>

                                    </td>
                                </tr>
                            </volist>
                            <else/>
                            <td colspan="14" class="text-center"> aOh! 暂时还没有内容!</td>
                        </notempty>
                        </tbody>
                    </table>


                </div>
                <div class="page" style="float:left;margin-right:300px;">{$_page}</div>


                <style type="text/css">

                    #tab1 ._block {
                        width: 100%;
                        height: 100%;
                        background: rgba(0, 0, 0, 0.4);
                        position: fixed;
                        top: 0;
                        left: 0;
                    }

                    #tab1 ._block .center {
                        width: 35%;
                        height: 87%;
                        margin: auto;
                        margin-top: 4%;
                        border-radius: 10px 10px;
                        background: #fff;
                        background: rgba(112, 188, 243, 0.95);
                        border: #70bcf3;
                        padding: 1% 1%;
                    }

                    #tab1 ._block form {

                    }

                    #tab1 ._block label {
                        display: block;
                        margin-bottom: 2%;
                    }

                    #tab1 ._block .font {
                        float: left;
                        width: 27%;
                        text-align: right;
                        /*background: #fde;*/
                        margin-right: 3%;
                        font-size: 14px;

                    }

                    #tab1 .add_block {
                        display: none;
                    }
                </style>

                <div class="_block add_block">
                    <div class="center">
                        <form action="{:U('saveMobilePay')}" method="post">
                            <label>
                                <font class="font">类型：</font>
                                <select  name="type">
                                    <!-- 1=手机网站支付,4=手机网站支付花呗,5=当面付信用卡 -->
                                    <option value="0">- 请选择 -</option>
                                    <option value="1">手机网站支付</option>
                                    <option value="4">手机网站支付花呗</option>
                                    <option value="5">当面付信用卡</option>
                                </select>
                            </label>
                            <label>
                                <font class="font">账号：</font><input type="text" name="account" style="">
                            </label>

                            <label>
                                <font class="font">名称：</font><input type="text" name="name" style="">
                            </label>


                            <label>
                                <font class="font">APPID：</font><input type="text" name="appid" style="">
                            </label>
                            <label>
                                <font class="font">Pid：</font><input type="text" name="pid" style="">
                            </label>

                            <label>
                                <font class="font">秘钥：</font><textarea name="secret"
                                                                       style="width:70%;height:51%"></textarea>
                            </label>
                            <label>
                                <font class="font">公钥：</font><textarea name="public"
                                                                       style="width:70%;height:20%"></textarea>
                            </label>

                            <label>
                                <font class="font">转出费率：</font><input type="text" name="rate_out" style="">
                            </label>

                            <label>
                                <font class="font">到账支付宝账号：</font><input type="text" name="to_alipay" style="">
                            </label>

                            <label>
                                <font class="font">成本费率：</font><input type="text" name="chengben" style="">
                            </label>

                            <label>
                                <font class="font">最小额度：</font><input type="text" name="min_quota" style="">
                            </label>

                            <label>
                                <font class="font">最高额度：</font><input type="text" name="max_quota" style="">
                            </label>

                            <label>
                                <button type="button" class="btn add_sure" style="width:27%;float:right">确 定</button>
                            </label>


                        </form>

                    </div>
                </div>


                <div class="inner_block">

                </div>


            </div>

            <!-- 提现支付宝配置 -->
            <div id="tab3" class="tab-pane tab3">
                <php>$info=D('Adata')->find();</php>
                <form action="{:U()}" method="post" class="form-horizontal">


                    <!--<div class="form-item">-->
                        <!--<label class="item-label">收款支付宝appid</label>-->
                        <!--<div class="controls">-->
                            <!--<input type="text" style="height:30px;" class="text input-large" name="appid"-->
                                   <!--value="{$info.appid}">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="form-item">-->
                        <!--<label class="item-label">收款支付宝secret</label>-->
                        <!--<div class="controls">-->
                            <!--<textarea name="secret" style="width:900px;height:300px;border:1px solid #ccc"-->
                                      <!--value="{$info.secret}">{$info.secret}</textarea>-->
                            <!--&lt;!&ndash; <input type="text" style="height:30px;" class="text input-large" name="secret"  value="{$info.secret}"> &ndash;&gt;-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="form-item">-->
                        <!--<label class="item-label">收款支付宝public</label>-->
                        <!--<div class="controls">-->
                            <!--<textarea name="public" style="width:900px;height:100px;" value="{$info.public}">{$info.public}</textarea>-->
                            <!--&lt;!&ndash; <input type="text" style="height:30px;" class="text input-large" name="public" value="{$info.public}"> &ndash;&gt;-->
                        <!--</div>-->
                    <!--</div>-->


                    <div class="form-item">
                        <label class="item-label">分账支付宝partnerid</label>
                        <div class="controls">
                            <input type="text" style="height:30px;" class="text input-large" name="t_account"
                                   value="{$info.t_account}">
                        </div>
                    </div>

                    <div class="form-item">
                        <label class="item-label">提现支付宝appid</label>
                        <div class="controls">
                            <input type="text" style="height:30px;" class="text input-large" name="tx_appid"
                                   value="{$info.tx_appid}">
                        </div>
                    </div>
                    <div class="form-item">
                        <label class="item-label">提现支付宝secret</label>
                        <div class="controls">
                            <textarea name="tx_secret" style="width:900px;height:300px;" value="{$info.tx_secret}">{$info.tx_secret}</textarea>
                            <!-- <input type="text" style="height:30px;" class="text input-large" name="tx_secret" value="{$info.tx_secret}"> -->
                        </div>
                    </div>
                    <div class="form-item">
                        <label class="item-label">提现支付宝public</label>
                        <div class="controls">
                            <textarea name="tx_public" style="width:900px;height:100px;" value="{$info.tx_public}">{$info.tx_public}</textarea>
                            <!-- <input type="text" style="height:30px;" class="text input-large" name="tx_public" value="{$info.tx_public}"> -->
                        </div>
                    </div>


                    <div class="form-item" style="color:red">
                        更换时，appid、secret、public缺一不可，secret、public必须使用RSA2且必须对应，不可带空格或者换行，千万不要改成空的进行保存！
                    </div>


                    <div class="form-item">
                        <button class="btn submit-btn" id="submit" type="button" target-form="form-horizontal">确 定
                        </button>
                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>

                    </div>


                </form>

            </div>

        </div>


    </div>

    <!-- <button type="button" id='kkcs'>短信测试</button> -->
</block>
<block name="script">
    <script type="text/javascript" src="__STATIC__/jquery.dragsort-0.5.1.min.js"></script>


    <script type="text/javascript">
        Think.setValue("extend", {$info.extend |
        default
        = 0
        })
        ;
        //导航高亮
        highlight_subnav('{:U('
        set_alipay
        ')}'
        )
        ;


        $(function () {
            showTab();
        })


    </script>

    <!-- 手机网站支付配置  -->
    <script type="text/javascript">

//        $(".btn test_alipay").hover(function () {
//
//            $('#qrcode_div').show();
//        });

        function qrcode_div_click(id) {
            $('#qrcode_div'+id).show();
        }

        //点击隐藏
        $("#tab1 .add_block .center").click(function (e) {
            $('#tab1 .add_block ').show();
            e.stopPropagation();//阻止冒泡
        });
        $(' #tab1 .add_block').click(function () {
            $("#tab1 .add_block").hide();

        })


        $('#tab1 .add_alipay').click(function () {
            $('#tab1 .add_block').show()
        })

        $('#tab1 .add_block .add_sure').click(function () {
            var data = $(' #tab1 .add_block form').serializeArray();
            console.log(data);
            var url = "{:U('Alipay/addalipay')}";
            $.ajax({
                type: 'post',
                url: url,
                data: {'data': data},
                success: function (m) {
                    console.log(m);
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('添加失败')
                    }

                }
            })


        })


        $('#tab1 .edit_alipay').click(function () {
            var id = $(this).parent().parent().find('.ids').val()
            // alert(id)
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '2'},
                dataType: 'json',
                success: function (m) {
                    // console.log(m)
                    // if(m.info!=''&&m.info==0){
                    //     alert('查找失败，请刷新重试')
                    // }else{


                    var str = ''
                    str += '<div class="_block edit_block">'
                    // alert(str)
                    str += '<div class="center">'
                    str += '<form action="" method="post">'
                    str += '<input name="id" class="id" type="hidden" value="' + m.id + '">'
                    str += '<label><font class="font">账号：</font><input type="text" name="account" value="' + m.account + '"></label>'

                    str += '<label><font class="font">名称：</font><input type="text" name="name" value="' + m.name + '"></label>'


                    str += '<label><font class="font">APPID：</font><input type="text" name="appid" value="' + m.appid + '"></label>'
                    str += '<label><font class="font">Pid：</font><input type="text" name="pid" value="' + m.pid + '"></label>'

                    str += '<label><font class="font">秘钥：</font><textarea name="secret" style="width:70%;height:51%">' + m.secret + '</textarea></label>'
                    str += '<label><font class="font">公钥：</font><textarea name="public" style="width:70%;height:20%">' + m.public + '</textarea></label>'

                    str += '<label><font class="font">转出费率：</font><input type="text" name="rate_out" value="' + m.rate_out + '"></label>'

                    str += '<label><font class="font">到账支付宝账号：</font><input type="text" name="to_alipay" value="' + m.to_alipay + '"></label>'

                    str += '<label><button type="button" class="btn edit_sure" style="width:27%;float:right">确 定</button></label>'


                    str += '</form></div></div>'


                    $('.inner_block').html(str)

                    str = ''

                    // }
                }
            })


        })


        $('#tab1 .test_alipay').click(function () {
            $("#qrcode_div").show();
        });

        $(".inner_block").on('click', '.edit_block .center', function () {
            e.stopPropagation();//阻止冒泡
        })

        $('.inner_block ').click(function () {
            $('.inner_block').html('')

        })


        $(".inner_block").on('click', '.edit_block .edit_sure', function () {
            var data = $('.edit_block form').serializeArray();
            var url = "{:U('Alipay/alipay_list')}"
            var id = $('.inner_block .id').val()
            $.ajax({
                type: 'post',
                url: url,
                data: {'data': data, 'type': '3', 'id': id},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('修改失败')
                    }

                }
            })
        })


        $('#tab1  .delete_alipay').click(function () {
            var id = $(this).parent().parent().find('.ids').val()
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '4'},
                success: function (m) {
                    if (m > 0) {
                        console.log(m);
                        location.reload()
                    } else {
                        alert('删除失败')
                    }

                }
            })

        })


        $('#tab1  .to_change_alipay').click(function () {

            var id = $(this).parent().parent().find('.ids').val()
            var status = $(this).parent().find('.status').val()

            // alert(status)
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '5', 'status': status},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('操作失败')
                    }

                }
            })

        })


    </script>


    <!-- 提现支付宝配置 -->
    <script type="text/javascript">

        function qrcode_div_click(id) {
            $('#qrcode_div'+id).show();
        }

        //点击隐藏
        $("#tab3 .add_block .center").click(function (e) {
            $('#tab3 .add_block ').show();
            e.stopPropagation();//阻止冒泡
        });
        $(' #tab3 .add_block').click(function () {
            $("#tab3 .add_block").hide();

        })


        $('#tab3 .add_alipay').click(function () {
            $('#tab3 .add_block').show()
        })

        $('#tab3 .add_block .add_sure').click(function () {
            var data = $(' #tab3 .add_block form').serializeArray();
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'data': data, 'type': '1'},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('添加失败')
                    }

                }
            })


        })


        $('#tab3 .edit_alipay').click(function () {
            var id = $(this).parent().parent().find('.ids').val()
            // alert(id)
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '2'},
                dataType: 'json',
                success: function (m) {
                    // console.log(m)
                    // if(m.info!=''&&m.info==0){
                    //     alert('查找失败，请刷新重试')
                    // }else{


                    var str = ''
                    str += '<div class="_block edit_block">'
                    // alert(str)
                    str += '<div class="center">'
                    str += '<form action="" method="post">'
                    str += '<input name="id" class="id" type="hidden" value="' + m.id + '">'
                    str += '<label><font class="font">账号：</font><input type="text" name="account" value="' + m.account + '"></label>'

                    str += '<label><font class="font">名称：</font><input type="text" name="name" value="' + m.name + '"></label>'


                    str += '<label><font class="font">APPID：</font><input type="text" name="appid" value="' + m.appid + '"></label>'
                    str += '<label><font class="font">Pid：</font><input type="text" name="pid" value="' + m.pid + '"></label>'

                    str += '<label><font class="font">秘钥：</font><textarea name="secret" style="width:70%;height:51%">' + m.secret + '</textarea></label>'
                    str += '<label><font class="font">公钥：</font><textarea name="public" style="width:70%;height:20%">' + m.public + '</textarea></label>'

                    str += '<label><font class="font">转出费率：</font><input type="text" name="rate_out" value="' + m.rate_out + '"></label>'

                    str += '<label><font class="font">到账支付宝账号：</font><input type="text" name="to_alipay" value="' + m.to_alipay + '"></label>'

                    str += '<label><button type="button" class="btn edit_sure" style="width:27%;float:right">确 定</button></label>'


                    str += '</form></div></div>'


                    $('.inner_block').html(str)

                    str = ''

                    // }
                }
            })


        })


        $('#tab3 .test_alipay').click(function () {
            $("#qrcode_div").show();
        });

        $(".inner_block").on('click', '.edit_block .center', function () {
            e.stopPropagation();//阻止冒泡
        })

        $('.inner_block ').click(function () {
            $('.inner_block').html('')

        })


        $(".inner_block").on('click', '.edit_block .edit_sure', function () {
            var data = $('.edit_block form').serializeArray();
            var url = "{:U('Alipay/alipay_list')}"
            var id = $('.inner_block .id').val()
            $.ajax({
                type: 'post',
                url: url,
                data: {'data': data, 'type': '3', 'id': id},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('修改失败')
                    }

                }
            })
        })


        $('#tab3  .delete_alipay').click(function () {
            var id = $(this).parent().parent().find('.ids').val()
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '4'},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('删除失败')
                    }

                }
            })

        })


        $('#tab3  .to_change_alipay').click(function () {

            var id = $(this).parent().parent().find('.ids').val()
            var status = $(this).parent().find('.status').val()

            // alert(status)
            var url = "{:U('Alipay/alipay_list')}"
            $.ajax({
                type: 'post',
                url: url,
                data: {'id': id, 'type': '5', 'status': status},
                success: function (m) {
                    if (m > 0) {
                        location.reload()
                    } else {
                        alert('操作失败')
                    }

                }
            })

        })


    </script>







</block>

